---
category: DOM
created: '2020-04-19'
title: Check if an element is focused
updated: '2021-10-13'
---

**JavaScript version**

```js hasFocus.js
const hasFocus = (ele) => ele === document.activeElement;
```

**TypeScript version**

```ts hasFocus.ts
const hasFocus = (ele: Node): boolean => ele === document.activeElement;
```
